class Link < ActiveRecord::Base
validates_presence_of :name,:url
require 'net/http'

  def self.checklink(url)
    st=url.gsub(/.*:\/\//,'')
    host=st.gsub(/\/.*/,'')
    page=st.gsub(/^[a-z\.]*/,'')
    if page.empty?
    	page="/"
    end
    a=Net::HTTP.new(host.to_s,80).get(page.to_s).message
    return a
  end

end
